#include<bits/stdc++.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=998244353;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
inline void Add(int &x,int y){(x=x+y+Mod)%=Mod;}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n;
struct THINGS{
	int c,t,w;
}z[N],a[N],gg[N];
int tot;
inline bool cmp(THINGS x,THINGS y){
	if(x.w*y.t==y.w*x.t) return x.t<y.t;
	return x.w*y.t>y.w*x.t;
};
inline bool cmb(THINGS x,THINGS y){
	return x.t<y.t;
};
pair<int,int> sta[N];
int tp,ans;
priority_queue<int>q;
inline int work(int ppp){
	For(i,1,n) a[i]=z[i];
//	printf("%lld\n",ans);
//	For(i,1,n) cout<<z[i].c<<" ";puts("");
//	For(i,1,n) cout<<z[i].t<<" ";puts("");
//	For(i,1,n) cout<<z[i].w<<" ";puts("");
		
	sort(a+1,a+n+1,cmb);
	int res=ans;
	For(i,1,n){
		int k=min(a[i].c,ppp/a[i].t);
		ppp-=k*a[i].t;
		res+=k*a[i].w;
	}
	return res;
}
int dp[105][100005];
signed main(){
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read();
	int sum=0;
	For(i,1,n) z[i].c=read(),sum+=z[i].c;
	For(i,1,n) z[i].t=read();
	For(i,1,n) z[i].w=read();
	int V=read();
	if(sum<=20){
		For(i,1,n){
			For(j,1,z[i].c) {
				gg[++tot]=z[i];
			}
		}
		int ans=0;
		For(p,0,(1<<tot)-1){
			int v=0,val=0;
			For(i,1,tot){
				if(p&(1<<(i-1))){
					v+=gg[p].t;
					val+=gg[p].w;
				}
			}
			if(v<=V){
				ans=max(ans,val);
			}
		}
		printf("%lld\n",ans);
		return 0;
	}
	if(V<=10000){
		dp[0][V]=1;
		For(i,1,n){
			For(v,0,V){
				For(j,0,min(z[i].c,V/z[i].t)){
					dp[i][v+j*z[i].t]=max(dp[i][v+j*z[i].t],dp[i-1][v]+j*z[i].w);
				}
			}
		}
		int ans=0;
		For(v,0,V) ans=max(ans,dp[n][v]);
		printf("%lld\n",ans);
		return 0;
	}
	sort(z+1,z+n+1,cmp);
	int x=V;
	For(i,1,n){
		int k=min(z[i].c,x/z[i].t);
		x-=k*z[i].t;
		ans+=k*z[i].w;
		z[i].c-=k;
		if(k!=0)sta[++tp]={i,k};
		
	}
	int res=ans;
	For(j,1,100000){
		int p=sta[tp].second;
		sta[tp].second--;
		z[sta[tp].first].c++;
		x+=z[sta[tp].first].t;
		ans-=z[sta[tp].first].w;
		if(sta[tp].second==0) tp--;
		res=max(res,work(x));
		if(tp==0) break;
	}
	printf("%lld\n",res);
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

